import { ecs } from "./ECS";
import { ECSEntity } from "./ECSEntity";

export class ECSGroup<E extends ECSEntity = ECSEntity>{
    private matcher:ecs.IMatcher;

    private _matchEntities:Map<number,E> = new Map();

    private _entitiesCache:E[] | null  = null;

    get matchEntities(){
        if (this._entitiesCache === null) {
            this._entitiesCache = Array.from(this._matchEntities.values());
        }
        return this._entitiesCache;
    }
    
    constructor(matcher:ecs.IMatcher){
        this.matcher = matcher;
    }
    /**
     * 当前group中实体的数量
     * 
     * 注：不要手动修改这个属性值。
     * 注：其实可以通过this._matchEntities.size获得实体数量，但是需要封装get方法。为了减少一次方法的调用所以才直接创建一个count属性
     */
    count = 0;
    onComponentAddOrRemove(entity:E){

    }
    watchEntityEnterAndRemove(enteredEntities:Map<number,E>,removedEntities:Map<number,E>){

    }
}